// pages/dailydelivery/dailydelivery.js
var utils = require('../../utils/util.js');
Page({

  /**
   * 页面的初始数据
   */
  data: {

  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function(options) {
    var that = this;
    that.system();
  },
  //基本数据
  system: function(e) {
    var that = this;
    utils.http("/api/v1/common/system", {}, function(res) {
      that.setData({
        info: res.datas
      })
    })
  },
  //进入详情
  dailyDetailsTap: function(e) {
    wx.navigateTo({
      url: '../dailydelivery/dailyDetails/dailyDetails',
    })
  },
  formSubmit: function(e) {
    console.log(e);
    var name = e.detail.value.name;
    var phone = e.detail.value.phone;
    if (name != "" && (/^1(3|4|5|7|8)\d{9}$/.test(phone))) {
      utils.http("/api/v1/common/add_day_order", {
        name: name,
        contact: phone
      }, function(res) {
        if (res.state == 1) {
          wx.showToast({
            title: '您已提交成功，请等待联系~',
            icon: "none"
          })
        }
      })
    } else {
      if (!(/^1(3|4|5|7|8)\d{9}$/.test(phone))) {
        wx.showToast({
          title: '手机号错误哦~',
            image: 'https://xinong.qidian2018.com/smimgs/error.png',
        })
      }
      if (name == "") {
        wx.showToast({
          title: '请输入姓名',
            image: 'https://xinong.qidian2018.com/smimgs/error.png',
        })
      }
    }
  }
})